﻿using System.Collections;
using FlowCanvas;
using FlowCanvas.Nodes;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    [Category("Ggame")]
    public class SwitchCallLuaFunc : FlowControlNode
    {
        [RequiredField]
        public BBParameter<string> funcName;
        public BBParameter<string> stringArg;

        protected override void RegisterPorts()
        {
            var caseTrue = AddFlowOutput("True");
            var caseFalse = AddFlowOutput("False");
            var caseThen = AddFlowOutput("Then");
            AddFlowInput("In", (f) =>
            {
                bool isTrue = BlueprintUtils.CallLuaFuncSwitch(funcName.value, stringArg.value);
                if (isTrue)
                {
                    f.Call(caseTrue);
                }
                else
                {
                    f.Call(caseFalse);
                }
                
                f.Call(caseThen);
            });

        }
    }
}